# Contributor: Mark Pashmfouroush <mark@markpash.me>
# Maintainer: Mark Pashmfouroush <mark@markpash.me>
pkgname=conntracct
pkgver=0.2.7
pkgrel=26
pkgdesc="Tool for extracting network flow information from Linux hosts"
url="https://github.com/ti-mo/conntracct"
license="Apache-2.0"
# loongarch64: blocked by golang.org/x/sys
arch="all !loongarch64"
options="net !check" # can't load and test BPF probes in CI
makedepends="go mage"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/ti-mo/conntracct/archive/$pkgver.tar.gz
	conntracct.confd
	conntracct.initd
	dont-run-setcap.patch
	fix-cgo.patch
	"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mage build
}

check() {
	go test -v \
		-coverprofile=test/output/integration.cover \
		-covermode=atomic \
		-tags=integration ./... \
		-exec=sudo
}

package() {
	install -Dm644 "$srcdir"/conntracct.confd "$pkgdir"/etc/conf.d/conntracct
	install -Dm755 "$srcdir"/conntracct.initd "$pkgdir"/etc/init.d/conntracct
	install -Dm755 "$builddir"/build/conntracct "$pkgdir"/usr/bin/conntracct
	install -d "$pkgdir"/etc/conntracct
}

sha512sums="
f018116dbeb937a5e308fa05dcbe9633ee1227a3bdce6c946cca1c5d73bb463c0085835c042becc62f7ad597b243c470c06e9712a1dffb844c4c858615da09af  conntracct-0.2.7.tar.gz
e2474f6a0fd86014ec87c662cbb3f51a906e3d5905ad7d77e557a3c42c1efaeace40dd0e3811c75536bb6b031be68453e7e945786ef1af158398424fba5213a8  conntracct.confd
6654dc698e93e384b72186454494fe5df92ad99d915b60b58301e75e31eaac532614b7e7856a36d7be487fae5f3c4fbd9fae1ef6df2ff83cee91f5e412240398  conntracct.initd
911a1e8d761071c2c8c077b7b6306c11aa318a671576ccc14486d70118a15eab4850257996f991b92e462b0897ac6e917007009696cd32885c344ffa5966c2e4  dont-run-setcap.patch
2d27248ac1499cb1f240b3290c31cdfec6e360fb34e158b1578013742d1919df8f938a3efab5b52a739331eeff1d766f046c1dd8a0d752a8a7b2d620bc323f3f  fix-cgo.patch
"
